#include "setqtimer.h"
#include "ui_setqtimer.h"

SetQTimer::SetQTimer(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::SetQTimer)
{
    ui->setupUi(this);
    qTimer = new QTimer();
    static int i = 0;
    connect(qTimer,&QTimer::timeout,
            [=](){
        ui->lcdNumber->display(i++);
    });
}

SetQTimer::~SetQTimer()
{
    delete ui;
}

void SetQTimer::on_StartButton_clicked()
{
    if (!qTimer->isActive()) {
        qTimer->start(1000);
    }
}

void SetQTimer::on_StopButton_clicked()
{
    qTimer->stop();
}
